﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.Odbc;
using System.Data.OleDb;
using System.Configuration;
using System.Data.SqlClient;

public partial class Login : System.Web.UI.Page
{
    ServiceReference1.MyWebServiceSoapClient servis = new ServiceReference1.MyWebServiceSoapClient();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Username"] != null)
        {
             Response.Redirect("Game.aspx");
        }

    }
   
    protected void Button1_Click(object sender, EventArgs e)
    {

        ServiceReference1.User tmpUser = servis.loginUser(TextBox3.Text, TextBox4.Text);

        if (tmpUser.Username != "")
        {
            Session["Username"] = tmpUser.Username;
            Session["Name"] = tmpUser.FirstName + " " + tmpUser.LastName;
            Session["Picture"] = tmpUser.PicturePath;
            Response.Redirect("Game.aspx");
        }
        else
        {
            Label1.Text = tmpUser.errorMessage;
        }
       

        
       
    }
}